import { IStageAssetsInfo, Stage } from "babylon-lib/base/stage";
import { Scene } from "@babylonjs/core/scene";
import { Camera } from "@babylonjs/core/Cameras/camera";
import { Light } from "@babylonjs/core/Lights/light";
import { ILoose } from "babylon-lib/tool/utils";
import { AbstractAssetTaskInfo, GLTFMeshTaskInfo, TextureTaskInfo } from "babylon-lib/loader/asset-task-info";
import { DeviceInputPreset } from "babylon-lib/preset/device-input/device-input-preset";
import { PhysicsManager } from "../../../common/physics/physicsManager";
import { InitializeHub } from './components/initialize-hub';
import { RawAssetsUrl } from "../raw-assets-info";


class DefaultStage extends Stage {

    protected assetTaskInfos(): ILoose<AbstractAssetTaskInfo> | Array<IStageAssetsInfo> {
        return Object.assign({}, [
            new TextureTaskInfo(RawAssetsUrl.textureCircle),
            new TextureTaskInfo(RawAssetsUrl.textureRound),
        ]) as unknown as ILoose<AbstractAssetTaskInfo>;
    }

    public render(): void {
        this.mainScene.render();
    }

    protected async initializeComponents(scenes: Scene[], cameras: Camera[], lights: Light[]): Promise<void> {

        DeviceInputPreset.initialize(this.mainScene, {
            checkInterval: 100
        });

        await PhysicsManager.initialize(this);
        InitializeHub.initialize(this);

    }
}


export { DefaultStage };